package com.easyj.admin.sys.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import com.easyj.base.common.ajax.Result;
import com.easyj.base.controller.BaseController;
import com.easyj.base.exception.EasyjException;
import com.easyj.base.exception.ValidateException;
import java.util.List;
import com.easyj.admin.db.model.SysParams;
import com.easyj.admin.sys.service.SysParamsService;
	/**
	* 系统参数设置
	*
	 */
	@RestController
	@RequestMapping(value = "/sys/sysparams")
	public class SysParamsController extends BaseController{

		@Autowired
		private  SysParamsService sysParamsService;

		/**
		 * get
		 * @param id
		 * @return
		 */
	    @GetMapping("/{id}")
	    public Result get(@PathVariable("id") String id) {
	        SysParams entity = sysParamsService.findById(id);
	        return Result.Success(entity);
	    }
		
		
		
		
		/**
		* 修改
		*/
		@PreAuthorize("hasPermission('sysParams','sysParams:all')")
		@PutMapping
		public Result update(@RequestBody @Validated SysParams entity,BindingResult validResult) throws EasyjException{
			
            if(validResult.hasErrors()) {
				throw new ValidateException("数据不符合要求！");
			}  			
			sysParamsService.updateEntity(entity);
			return Result.Success();
			
		}
		/**
		* 查询
		* @param filter
		* @return
		 */
		@PostMapping(value = "findList")
		public Result findList(@RequestBody  SysParams filter) {
			List<SysParams>  list =sysParamsService.findList(filter);
			return Result.Success(list);
			
		}
		
      
 		

}

